using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Ads_Picture;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Ads_Picture
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOAds_Picture_Select_All action = new BOAds_Picture_Select_All();
                usp_Ads_Picture_Select_All entity = new usp_Ads_Picture_Select_All();
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }        
        public static DataTable SelectByModule(int module_id)
        {
            try
            {
                BOAds_Picture_Select_By_Module action = new BOAds_Picture_Select_By_Module();
                usp_Ads_Picture_Select_By_Module entity = new usp_Ads_Picture_Select_By_Module();
                entity.MODULE_ID = module_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOAds_Picture_Select_Top action = new BOAds_Picture_Select_Top();
                usp_Ads_Picture_Select_Top entity = new usp_Ads_Picture_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTopRandomModule(int rows, int status, int module)
        {
            try
            {
                BOAds_Picture_Select_Top_Random_By_Module action = new BOAds_Picture_Select_Top_Random_By_Module();
                usp_Ads_Picture_Select_Top_Random_By_Module entity = new usp_Ads_Picture_Select_Top_Random_By_Module();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                entity.MODULE = module;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int picture_id)
        {
            try
            {
                BOAds_Picture_Search action = new BOAds_Picture_Search();
                usp_Ads_Picture_Search entity = new usp_Ads_Picture_Search();
                entity.PICTURE_ID = picture_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Expires(int leftday)
        {
            try
            {
                BOAds_Picture_Expires action = new BOAds_Picture_Expires();
                usp_Ads_Picture_Expires entity = new usp_Ads_Picture_Expires();
                entity.LeftDay = leftday;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOAds_Picture_Select_WithPaged action = new BOAds_Picture_Select_WithPaged();
                usp_Ads_Picture_Select_WithPaged entity = new usp_Ads_Picture_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByType(int startIndex, int pageCount, int type)
        {
            try
            {
                BOAds_Picture_Select_By_Type action = new BOAds_Picture_Select_By_Type();
                usp_Ads_Picture_Select_By_Type entity = new usp_Ads_Picture_Select_By_Type();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.TYPE_ID = type;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(int module_id, string picture_name_vn, string url, string target_link,  bool is_display_on_home_page, int sort_display, DateTime created_date, string created_by, DateTime modify_date, DateTime end_date, string modify_by, bool status)
        {
            try
            {
                BOAds_Picture_Insert action = new BOAds_Picture_Insert();
                usp_Ads_Picture_Insert entity = new usp_Ads_Picture_Insert();
                entity.MODULE_ID = module_id;
                entity.PICTURE_NAME_VN = picture_name_vn;
                entity.URL = url;
                entity.TARGET_LINK = target_link;                
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.END_DATE = end_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(int picture_id, int module_id, string picture_name_vn, string url, string target_link, bool is_display_on_home_page, int sort_display, DateTime created_date, string created_by, DateTime modify_date, DateTime end_date, string modify_by, bool status)
        {
            try
            {
                BOAds_Picture_Update action = new BOAds_Picture_Update();
                usp_Ads_Picture_Update entity = new usp_Ads_Picture_Update();
                entity.PICTURE_ID = picture_id;
                entity.MODULE_ID = module_id;
                entity.PICTURE_NAME_VN = picture_name_vn;
                entity.URL = url;
                entity.TARGET_LINK = target_link;                
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.SORT_DISPLAY = sort_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.END_DATE = end_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int picture_id)
        {
            try
            {
                BOAds_Picture_Delete action = new BOAds_Picture_Delete();
                usp_Ads_Picture_Delete entity = new usp_Ads_Picture_Delete();
                entity.PICTURE_ID = picture_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int picture_id)
        {
            try
            {
                BOAds_Picture_Restore action = new BOAds_Picture_Restore();
                usp_Ads_Picture_Restore entity = new usp_Ads_Picture_Restore();
                entity.PICTURE_ID = picture_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

